package org.jeecg.util;

import org.apache.ibatis.jdbc.ScriptRunner;

import java.io.File;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @Description: 关于app
 * @Author: zj
 * @Date: 2019-10-10
 * @Version: V1.0
 */

public class DataSQLUtils {


    public static String sources(String fileDir) throws ClassNotFoundException, SQLException {

        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://192.168.1.100:3308/jeecg2.1.3";
        String username = "root";
        String password = "root";
        File file = new File(fileDir);
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, username, password);
        ScriptRunner runner = new ScriptRunner(conn);
        try {
            runner.setStopOnError(true);
            runner.runScript(new FileReader(file));
        } catch (Exception e) {
            e.printStackTrace();
        }
        conn.close();

        return null;
    }

    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        sources("D:\\zj\\resources\\svn152\\jeecg-boot-parent\\jeecg-jiazhuang\\src\\test\\java\\org\\jeecg\\jeecg-boot.sql");
    }

}
